#coding:utf-8
# from tornado.wsgi import WSGIContainer
# from tornado.httpserver import HTTPServer
# from tornado.ioloop import IOLoop
#
# from manage import app
# from setting import openDbBase
#
# dbproconfig = openDbBase()
#
# http_server = HTTPServer(WSGIContainer(app))
# http_server.listen(dbproconfig['CHARTPORT'])  # flask默认的端口
# print('run...flask启动成功')
# IOLoop.current().start()


import threading
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop

from manage import app
from msgTkinter import msgTkinterClass
from setting import openDbBase

def sratTornado():
    dbproconfig = openDbBase()
    try:
        # msgTkinterClass().a001()
        http_server = HTTPServer(WSGIContainer(app))
        http_server.listen(dbproconfig['CHARTPORT'])  # flask默认的端口
        print('run...flask启动成功')
        IOLoop.current().start()
    except Exception as e:
        print('启动失败')
        # msgTkinterClass(isFail=True,msg=repr(e))
        msgTkinterClass().a001(isFail=True,msg=repr(e))

def sratMsg():
    msgTkinterClass().a001()

# 启动线程1进行弹窗提示
thread01 = threading.Thread(target=sratMsg, daemon=True, name="1")
thread01.start()
thread01.join()

# 启动服务
sratTornado()